package com.roy.galaxy.thread;

/**
 * @author gang.wang1903@xiaobao100.cn
 * @Date: 2019-10-09 16:16
 *
 * 如何停掉线程
 */
public class StopThread {


    public static void main(String[] args) throws InterruptedException {

        Thread thread1 = new Thread(()->{
            if(!Thread.currentThread().isInterrupted()) {
                System.out.println(Thread.currentThread().getName() + "正在执行");
            }
        },"t1");
        thread1.start();
        thread1.interrupt();  // Just to set the interrupt flag ,仅仅设置线程状态
        thread1.join();

    }


}
